import { shallowMount } from '@vue/test-utils';
import TodoList from '../../TodoList';
import Header from '../../components/Header';

describe('todoList组件测试',()=>{
  it('todoList初始化时，list应该为空',()=>{
    const wrapper = shallowMount(TodoList);
    const list = wrapper.vm.list;
    expect(list).toEqual([]);
  })

  it('todoList监听到header的add事件时，列表应该添加一条数据',()=>{
    const wrapper = shallowMount(TodoList);
    const header = wrapper.find(Header);

    header.vm.$emit('add','haha');
    const list = wrapper.vm.list;

    expect(list).toEqual(['haha']);

  })

})
